package pl.enigmatic.parser.markup;

import pl.enigmatic.parser.xml.ParsingInfo;
import pl.enigmatic.parser.xml.XMLParserExtension;


public class ReferenceExtension extends BasicMarkupExtension {

	public static final ReferenceExtension instance = new ReferenceExtension();

	private ReferenceExtension() {
		super("Ref");
	}

	@Override
	public boolean parse(final Object target, final MarkupProperties props, final ParsingInfo<?> info, final XMLParserExtension handler) {
		return handler.setParsedProperty(target, info, createInstance(props, info));
	}

	@Override
	public Object createInstance(MarkupProperties props, ParsingInfo<?> info) {
		return info.getNamedObject(props.getMainValue());
	}
}
